package com.i.template.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.i.template.domain.RechargeDO;
import com.i.template.mapper.RechargeMapper;
import com.i.template.service.IRechargeService;
import com.i.template.util.UserHolder;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

/**
 * @author lewis
 * @type class
 * @description
 * @since 2024/8/8
 */
@Service
public class RechargeServiceImpl extends ServiceImpl<RechargeMapper, RechargeDO> implements IRechargeService {

    @Override
    public Boolean expire() {
        Long userId = UserHolder.getUser();
        RechargeDO rechargeDO = lambdaQuery().eq(RechargeDO::getUserId, userId).orderByDesc(RechargeDO::getRechargeId).one();
        LocalDateTime createTime = rechargeDO.getCreateTime();
        if(createTime.plusMonths(rechargeDO.getMonth()).isAfter(LocalDateTime.now())) {
            return true;
        }
        return false;
    }
}
